<?php
if (!defined('BASEPATH'))
	exit('No direct script access allowed');
$this->load->view('header');
?>
<section class="grid_10" id="container">
    <fieldset>
		<legend><strong><?php echo $page_title ?></strong></legend>
		<div id="file_upload"  style="display: none;">
			
			<form id="file_upload_form" action="/posts/upload_image" method="POST" enctype='multipart/form-data' class="post_form">
				<p><strong>上传图片</strong></p>
				<p>
					<label for="album_id">图类：</label>
					<select name="album_id" id="album_id">
						<option value="1">宋可</option>
			<option value="2">程序</option>
			<option value="3">杂</option>
					</select>
				</p>
				<p>
				<lable for="image_description">描述：</lable>
				<input type="text" name="image_description" id="image_description" />
				</p>
				<p>
					<label for="album_userfile">图片：</label>
					<input type="file" name="userfile" id="album_serfile"/>
					<input type="submit" value="上传"/>
				</p>
			</form>
			<ul id="file_upload_list">
				
			</ul>
		</div>
		<form action="/posts/edit_post/" method="POST" class="post_form">
			<p>
				<label for="post_title">标题：</label>
				<input type="text" name="post_title" id="post_title" value="<?php echo $post->post_title; ?>" />
			</p>
			<p>
				<label for="post_content">内容：</label>
				<textarea id="post_content" class="content" name="post_content" cols="80" rows="20" ><?php echo $post->post_content; ?></textarea>
				<input type="hidden" name="ID" value="<?php echo $post->ID; ?>" />
			</p>
			<p><input type="submit" value="提交"/> <input type="reset" value="重置"/></p>
		</form>
    </fieldset>
	<script type="text/javascript" src="<?php echo base_url(); ?>js/Markitup/jquery.markitup.js"></script>
    <script type="text/javascript" src="<?php echo base_url(); ?>js/Markitup/skins/bbcode/set.js"></script>
    <script type="text/javascript" src="<?php echo base_url(); ?>js/Jquery/jquery.form.js"></script>
    <script type="text/javascript">
		function uploadImg(){
			$('#file_upload').toggle();
		}
		function form_insert_image(name,alt){
			$.markItUp({  
				openWith:'[img='+name+']'+alt,
				closeWith:'[\/img]',
				placeHolder:document.getSelection()
			}
		);
		}
		function showResponse(data)  { 
			$('#file_upload_list').append(data+'\n');
		}
		$('document').ready(function(){
			$('head').append('<link rel="stylesheet" href="<?php echo base_url(); ?>js/Markitup/skins/simple/style.css" media="screen"/>');
			$('head').append('<link rel="stylesheet" href="<?php echo base_url(); ?>js/Markitup/skins/bbcode/style.css" media="screen"/>');
			$(".content").markItUp(mySettings);
			var options = {
				success:       showResponse
			}
			$('#file_upload_form').ajaxForm(options); 
		});
    </script>
</section>
<aside class="grid_2">
    <ul>
		<li>添加文章</li>
		<li>修改文章</li>
    </ul>
</aside>
<?php
$this->load->view('footer');
?>